package com.hhkj.study.admin.course.enums;

import cn.hutool.core.util.StrUtil;
import com.google.common.collect.Lists;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.List;

/**
 * 课程关联的资源类型
 * @Author luowu
 * @Date 2024/10/9 涵 17:05:07
 */
@AllArgsConstructor
@Getter
public enum CourseAssocResourceTypeEnum {
    /**
     * 关联的资源类型
     */
    VIDEO("video", "视频"),

    LIVE("live", "直播"),

    DOC("doc", "资料"),

    QUESTION("question", "题库"),

    OFFLINE("offline", "线下课"),

    ;

    /** 能关联其他资源的资源类型 */
    public static final List<String> CAN_ASSOC_RESOUCE_TYPE_LIST = Lists.newArrayList(VIDEO.getCode(), LIVE.getCode());

    /** 有url链接资源类型 */
    public static final List<String> HAS_URL_RESOUCE_TYPE_LIST = Lists.newArrayList(DOC.getCode(), LIVE.getCode());

    /** 能关联题库的资源类型 */
    public static final List<String> CAN_ASSOC_BANK_TYPE_LIST = Lists.newArrayList(VIDEO.getCode(), LIVE.getCode(), OFFLINE.getCode());

    /** 开播时间  课程资源 */
    public static final List<String> HAS_STRAT_DATE_TYPE_LIST = Lists.newArrayList(LIVE.getCode(), OFFLINE.getCode());

    private String code;

    private String desc;


    public static CourseAssocResourceTypeEnum getEnumByCode(String code) {
        for (CourseAssocResourceTypeEnum item : CourseAssocResourceTypeEnum.values()) {
            if (StrUtil.equalsIgnoreCase(item.getCode(), code)) {
                return item;
            }
        }
        return null;
    }

    @Override
    public String toString() {
        return code;
    }
}
